<template>
  <div class="app-container profile-container">
    <div class="profile-header">
      <div class="profile-bg">
        <div class="bg-rails"></div>
        <div class="bg-train"></div>
      </div>
      <div class="profile-title">个人中心</div>
    </div>
    
    <el-row :gutter="24" class="profile-content">
      <el-col :span="6" :xs="24">
        <div class="profile-card user-card">
          <div class="card-ribbon"></div>
          <div class="user-info-header">
            <div class="user-avatar-wrapper">
              <userAvatar />
              <div class="avatar-ring"></div>
            </div>
            <div class="user-name-display">
              <span class="user-name-text">{{ user.nickName }}</span>
              <div class="name-decoration"></div>
            </div>
            <div class="user-account">{{ user.userName }}</div>
          </div>
          
          <div class="user-info-list">
            <div class="info-item">
              <div class="info-icon">
                <svg-icon icon-class="user" />
              </div>
              <div class="info-content">
                <span class="info-label">用户名称</span>
                <span class="info-value">{{ user.userName }}</span>
              </div>
            </div>
            
            <div class="info-item">
              <div class="info-icon">
                <svg-icon icon-class="phone" />
              </div>
              <div class="info-content">
                <span class="info-label">手机号码</span>
                <span class="info-value">{{ user.phonenumber || '未设置' }}</span>
              </div>
            </div>
            
            <div class="info-item">
              <div class="info-icon">
                <svg-icon icon-class="email" />
              </div>
              <div class="info-content">
                <span class="info-label">用户邮箱</span>
                <span class="info-value">{{ user.email || '未设置' }}</span>
              </div>
            </div>
            
            <div class="info-item">
              <div class="info-icon">
                <svg-icon icon-class="peoples" />
              </div>
              <div class="info-content">
                <span class="info-label">所属角色</span>
                <span class="info-value">{{ roleGroup || '无角色' }}</span>
              </div>
            </div>
            
            <div class="info-item">
              <div class="info-icon">
                <svg-icon icon-class="date" />
              </div>
              <div class="info-content">
                <span class="info-label">创建日期</span>
                <span class="info-value">{{ user.createTime }}</span>
              </div>
            </div>
          </div>
        </div>
      </el-col>
      
      <el-col :span="18" :xs="24">
        <div class="profile-card detail-card">
          <div class="detail-header">
            <div class="detail-title">基本资料</div>
            <div class="detail-decoration"></div>
          </div>
          
          <div class="detail-content">
            <el-tabs v-model="activeTab" class="custom-tabs">
              <el-tab-pane label="基本资料" name="userinfo">
                <div class="tab-content-wrapper">
                  <userInfo :user="user" />
                </div>
              </el-tab-pane>
              <el-tab-pane label="修改密码" name="resetPwd">
                <div class="tab-content-wrapper">
                  <resetPwd />
                </div>
              </el-tab-pane>
            </el-tabs>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import userAvatar from "./userAvatar";
import userInfo from "./userInfo";
import resetPwd from "./resetPwd";
import { getUserProfile } from "@/api/system/user";

export default {
  name: "Profile",
  components: { userAvatar, userInfo, resetPwd },
  data() {
    return {
      user: {},
      roleGroup: {},
      postGroup: {},
      activeTab: "userinfo"
    };
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.profile-container {
  min-height: calc(100vh - 84px);
  position: relative;
  padding-bottom: 30px;
  background-color: #f0f2f5;
  
  .profile-header {
    position: relative;
    height: 200px;
    margin-bottom: -80px;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    
    .profile-bg {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(135deg, #3a5e82 0%, #2c4662 100%);
      z-index: 1;
      
      &:before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-image: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
        background-size: 20px 20px;
        opacity: 0.3;
      }
      
      .bg-rails {
        position: absolute;
        bottom: 20px;
        left: 0;
        width: 100%;
        height: 4px;
        background-color: rgba(255,255,255,0.15);
        
        &:before {
          content: "";
          position: absolute;
          bottom: 10px;
          left: 0;
          width: 100%;
          height: 4px;
          background-color: rgba(255,255,255,0.15);
        }
        
        &:after {
          content: "";
          position: absolute;
          left: 0;
          right: 0;
          bottom: -4px;
          height: 20px;
          background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.15), rgba(255,255,255,0.15) 10px, transparent 10px, transparent 20px);
        }
      }
      
      .bg-train {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        left: -100px;
        width: 80px;
        height: 20px;
        background-color: rgba(255,255,255,0.3);
        border-radius: 5px 30px 0 5px;
        animation: trainMoveLeftToRight 15s infinite linear;
        
        &:before {
          content: "";
          position: absolute;
          bottom: -4px;
          right: 15px;
          width: 60px;
          height: 10px;
          background-color: rgba(255,255,255,0.2);
          border-radius: 5px;
        }
      }
    }
    
    .profile-title {
      position: relative;
      z-index: 3;
      padding: 30px;
      font-size: 28px;
      font-weight: 600;
      color: #fff;
      text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
      background: linear-gradient(90deg, #fff, #e0e0e0);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      letter-spacing: 1px;
    }
  }
  
  .profile-content {
    position: relative;
    z-index: 2;
    perspective: 1000px;
  }
  
  .profile-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.215, 0.61, 0.355, 1);
    transform-origin: center;
    
    &:hover {
      box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
      transform: translateY(-5px);
    }
  }
  
  .user-card {
    position: relative;
    
    .card-ribbon {
      position: absolute;
      top: -5px;
      right: 15px;
      width: 40px;
      height: 70px;
      background: linear-gradient(135deg, #4682b4 0%, #3a5e82 100%);
      z-index: 1;
      border-radius: 0 0 5px 5px;
      box-shadow: 0 5px 10px rgba(0,0,0,0.1);
      
      &:before, &:after {
        content: "";
        position: absolute;
        top: 0;
        border-style: solid;
        border-width: 5px;
      }
      
      &:before {
        left: -5px;
        border-color: #2c4662 #2c4662 transparent transparent;
      }
      
      &:after {
        right: -5px;
        border-color: #2c4662 transparent transparent #2c4662;
      }
    }
    
    .user-info-header {
      position: relative;
      padding: 40px 20px 20px;
      background: linear-gradient(0deg, #fff 0%, #f8f9fa 100%);
      border-bottom: 1px solid rgba(0, 0, 0, 0.05);
      text-align: center;
      
      .user-avatar-wrapper {
        position: relative;
        margin: 0 auto 15px;
        width: 100px;
        height: 100px;
        
        img {
          width: 100%;
          height: 100%;
          border-radius: 50%;
          border: 4px solid #fff;
          box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
          transition: all 0.3s ease;
          
          &:hover {
            transform: scale(1.05);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
          }
        }
        
        .avatar-ring {
          position: absolute;
          top: -8px;
          left: -8px;
          right: -8px;
          bottom: -8px;
          border: 2px dashed #4682b4;
          border-radius: 50%;
          animation: avatarRing 10s linear infinite;
          opacity: 0.6;
        }
      }
      
      .user-name-display {
        position: relative;
        display: inline-block;
        padding: 8px 25px;
        background: linear-gradient(135deg, #3a5e82 0%, #4682b4 100%);
        color: #fff;
        border-radius: 25px;
        font-size: 16px;
        font-weight: 600;
        box-shadow: 0 4px 10px rgba(58, 94, 130, 0.3);
        margin-bottom: 10px;
        overflow: hidden;
        
        .user-name-text {
          position: relative;
          z-index: 1;
        }
        
        .name-decoration {
          position: absolute;
          top: 0;
          left: 0;
          width: 200%;
          height: 100%;
          background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.2), rgba(255,255,255,0));
          transform: translateX(-100%);
          animation: nameShine 3s infinite;
        }
      }
      
      .user-account {
        font-size: 14px;
        color: #8c8c8c;
        margin-bottom: 5px;
      }
    }
    
    .user-stats {
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 15px;
      background-color: #fafbfc;
      
      .stat-item {
        flex: 1;
        text-align: center;
        
        .stat-value {
          font-size: 22px;
          font-weight: 600;
          color: #3a5e82;
        }
        
        .stat-label {
          font-size: 13px;
          color: #8c8c8c;
          margin-top: 5px;
        }
      }
      
      .stat-divider {
        width: 1px;
        height: 30px;
        background-color: rgba(0,0,0,0.1);
      }
    }
    
    .user-info-list {
      padding: 0;
      
      .info-item {
        display: flex;
        padding: 15px 20px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        transition: all 0.3s ease;
        
        &:last-child {
          border-bottom: none;
        }
        
        &:hover {
          background-color: rgba(0, 0, 0, 0.02);
          transform: translateX(5px);
        }
        
        .info-icon {
          flex: 0 0 36px;
          height: 36px;
          display: flex;
          align-items: center;
          justify-content: center;
          margin-right: 12px;
          background: linear-gradient(135deg, #f0f2f5 0%, #e6e9ed 100%);
          border-radius: 10px;
          color: #3a5e82;
          transition: all 0.3s ease;
          
          svg {
            font-size: 18px;
            transition: all 0.3s ease;
          }
        }
        
        &:hover .info-icon {
          background: linear-gradient(135deg, #3a5e82 0%, #4682b4 100%);
          color: #fff;
          transform: scale(1.1) rotate(5deg);
        }
        
        .info-content {
          flex: 1;
          display: flex;
          flex-direction: column;
          justify-content: center;
          
          .info-label {
            font-size: 12px;
            color: #8c8c8c;
            margin-bottom: 4px;
          }
          
          .info-value {
            font-size: 15px;
            color: #262626;
            font-weight: 500;
          }
        }
      }
    }
  }
  
  .detail-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #fff 0%, #f9fafc 100%);
    
    .detail-header {
      position: relative;
      padding: 25px 30px;
      border-bottom: 1px solid rgba(0, 0, 0, 0.05);
      
      .detail-title {
        font-size: 18px;
        font-weight: 600;
        color: #262626;
        letter-spacing: 0.5px;
      }
      
      .detail-decoration {
        position: absolute;
        top: 0;
        right: 40px;
        width: 120px;
        height: 5px;
        background: linear-gradient(90deg, #3a5e82, transparent);
        border-radius: 0 0 10px 10px;
      }
    }
    
    .detail-content {
      flex: 1;
      padding: 24px 30px;
    }
  }
  
  .tab-content-wrapper {
    position: relative;
    animation: fadeIn 0.5s ease;
  }
  
  .custom-tabs {
    ::v-deep .el-tabs__header {
      margin-bottom: 25px;
      padding-bottom: 5px;
    }
    
    ::v-deep .el-tabs__nav-wrap::after {
      height: 1px;
      background-color: rgba(0, 0, 0, 0.05);
    }
    
    ::v-deep .el-tabs__item {
      font-size: 15px;
      height: 50px;
      line-height: 50px;
      color: #595959;
      transition: all 0.3s;
      
      &.is-active {
        color: #3a5e82;
        font-weight: 600;
        transform: translateY(-2px);
      }
      
      &:hover {
        color: #4682b4;
      }
    }
    
    ::v-deep .el-tabs__active-bar {
      background: linear-gradient(90deg, #3a5e82, #4682b4);
      height: 3px;
      border-radius: 3px;
      transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    }
  }
}

@keyframes trainMoveLeftToRight {
  0% { left: -100px; }
  100% { left: 100%; }
}

@keyframes avatarRing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes nameShine {
  0% { transform: translateX(-100%); }
  20%, 100% { transform: translateX(100%); }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .profile-container {
    .profile-header {
      height: 160px;
      margin-bottom: -60px;
      
      .profile-title {
        padding: 25px;
        font-size: 24px;
      }
    }
    
    .user-card {
      margin-bottom: 20px;
      
      .user-info-header {
        padding: 30px 15px 15px;
        
        .user-avatar-wrapper {
          width: 80px;
          height: 80px;
        }
      }
    }
    
    .detail-card {
      .detail-header {
        padding: 20px 25px;
      }
      
      .detail-content {
        padding: 20px 25px;
      }
    }
  }
}
</style>

